{include file="header"}
<div style="padding: 20px;" class="adminmyucms">
<div style="background-color: #ddffff!important;padding: 14px;border-left: 6px solid #ccc!important;border-color: #2196F3!important;">
<p>
{:fun_sc_p('adCate', array('in'=>input('in')), 'content')}   <a href="/admin.php/ad/cate.html" type="button" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe674;</i> 返回分类</a>
</p>
</div>
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$v.id}">	
<input type="hidden" name="in" value="{:input('in')}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="200">
    <col width="500">
    <col width="200">
    <col width="100">
    <col width="200">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>广告ID</th>
      <th>备注</th>
      <th>广告内容</th>
      <th>到期时间</th>
      <th>排序</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td><input type="number" name="tid" value=""  placeholder="ID" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><input type="text" name="title" value=""  placeholder="备注名称" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><textarea name="content"  placeholder="请输入内容" class="layui-textarea"></textarea></td>
      <td><input type="text" id="time" name="times" value=""  placeholder="到期时间" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><input type="number" name="px" value="1"  placeholder="排序" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><button class="layui-btn" lay-submit lay-filter="set-add">添加广告</button></td>
    </tr>
  </tbody>
</table>
</form>
 
{foreach name=":fun_S('ad',array('in'=>input('in')),'tid desc','1000',1)" item="v" key="k"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$v.id}">	
<table class="layui-table">
  <colgroup>
    <col width="50">
    <col width="100">
    <col width="100">
    <col width="300">
    <col width="80">
    <col width="50">
    <col width="150">
    <col>
  </colgroup>
  <thead>
    <tr>
      <th>广告ID</th>
      <th>转移</th>
      <th>备注</th>
      <th>广告内容</th>
      <th>到期时间</th>
      <th>排序</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
    <tr>
      <td>
      	
      	<input type="number" name="tid" value="{$v.tid}"  placeholder="ID" autocomplete="off" lay-verify="required" class="layui-input">
      调用: &#123;:ad('{$v.tid}')&#125;
      </td>
      <td>
       <select name="in" lay-verify="required">
        <option value=""></option>
        {foreach name="muban" item="vq" key="k"}
        <option value="{$vq.name}" {if condition="$vq.name eq $v.in"}selected="selected"{/if}>{$vq.title}</option>
        {/foreach}
        
        {foreach name="mubanw" item="vs" key="k"}
        <option value="{$vs.name}" {if condition="$vs.name eq $v.in"}selected="selected"{/if}>{$vs.title}</option>
        {/foreach}
       </select>
      </td>
      <td><input type="text" name="title" value="{$v.title}"  placeholder="备注名称" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td><textarea name="content"  placeholder="请输入内容" class="layui-textarea" style="height:200px">{$v.content}</textarea></td>
      <td><input type="text" id="time{$v.id}" name="times" value="{$v.times||date='Y-m-d',###}"  placeholder="到期时间" autocomplete="off" lay-verify="required" class="layui-input"></td>
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#time{$v.id}'
  });
});
</script>
      <td><input type="number" name="px" value="{$v.px}"  placeholder="排序" autocomplete="off" lay-verify="required" class="layui-input"></td>
      <td id="admin_set">
      	<button class="layui-btn layui-btn-sm layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button>
      	<a class="layui-btn layui-btn-sm layui-btn-normal" style="float: left;" data-method="admin_set" url="/admin.php/ad/sql.html?id={$v.id}"><i class="layui-icon">&#xe641;</i></a>
        <button type="button" class="layui-btn layui-btn-sm layui-btn-danger"  member-name="确定要删除这条广告吗" url="{:url("set/delete")}?id={$v.id}&m=ad" lay-submit lay-filter="delete" ><i class="layui-icon">&#xe640;</i> 删除</button>
      </td>
    </tr>
  </tbody>
</table>
</form>
{/foreach}
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;

  //更新
  form.on('submit(set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("ad/update")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //添加
  form.on('submit(set-add)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("ad/insert")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
})
layui.use('laydate', function(){
  var laydate = layui.laydate;
  laydate.render({
    elem: '#time'
  });
});
</script>
</div>  
{include file="footer"}